home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0429.dms / q0429.adf / libray / libtext / windy.c < prev    next >
C/C++ Source or Header  |  1991-08-08  |  2KB  |  70 lines

  1. /*
  2.  * windy.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * $Id: windy.c,v 4.0 91/07/17 14:44:25 kolb Exp Locker: kolb $
  17.  *
  18.  * $Log:    windy.c,v $
  19.  * Revision 4.0  91/07/17  14:44:25  kolb
  20.  * Initial version.
  21.  * 
  22.  */
  23. #include "texture.h"
  24. #include "windy.h"
  25.  
  26. /*
  27.  * Create and return a reference to a "windy" texture.
  28.  */
  29. WindyText *
  30. WindyCreate(scale, wscale, cscale, bscale, octaves, tscale, hscale, offset)
  31. Float scale, wscale, cscale, bscale, tscale, hscale, offset;
  32. int octaves;
  33. {
  34.     WindyText *windy;
  35.  
  36.     windy = (WindyText *)Malloc(sizeof(WindyText));
  37.     windy->scale = scale;
  38.     windy->windscale = wscale;
  39.     windy->chaoscale = cscale;
  40.     windy->bumpscale = bscale;
  41.     windy->tscale = tscale;
  42.     windy->hscale = hscale;
  43.     windy->offset = offset;
  44.     windy->octaves = octaves;
  45.     return windy;
  46. }
  47.  
  48. /*
  49.  * Apply a "windy" texture.
  50.  */
  51. void
  52. WindyApply(windy, prim, ray, pos, norm, gnorm, surf)
  53. WindyText *windy;
  54. Geom *prim;
  55. Ray *ray;
  56. Vector *pos, *norm, *gnorm;
  57. Surface *surf;
  58. {
  59.     Vector bump;
  60.  
  61.     Windy(pos, windy->windscale, windy->chaoscale, windy->bumpscale,
  62.           windy->octaves, windy->tscale, windy->hscale, windy->offset,
  63.           &bump);
  64.  
  65.     norm->x += windy->scale * bump.x;
  66.     norm->y += windy->scale * bump.y;
  67.     norm->z += windy->scale * bump.z;
  68.     VecNormalize(norm);
  69. }
  70.